﻿using System;
using Windows.Networking.Proximity;
using Windows.Networking.Sockets;

namespace JustinAngel.MindwaveSensor.WP8
{
    public interface IMindwaveSensor : IDisposable
    {
        /// <summary>
        /// Opens a bluetooth socket to a Mindwave Mobile headset and provide MindwaveSensorReadings. 
        /// </summary>
        void Start();

        /// <summary>
        /// Closes the open bluetooth socket to a Mindwave Mobile headset. 
        /// </summary>
        void Stop();

        /// <summary>
        /// Gets the current state of the Mindwave sensor. 
        /// </summary>
        MindwaveServiceState State { get; }

        /// <summary>
        /// Raised when the state of the bluetooth connection or data retrival changes. 
        /// </summary>
        event EventHandler<MindwaveStateChangedEventArgs> StateChanged;

        /// <summary>
        /// Gets the current reading from the Mindwave Mobile Headset. 
        /// </summary>
        MindwaveReading CurrentValue { get; }

        /// <summary>
        /// Raised when a new MindwaveReading is available. 
        /// </summary>
        event EventHandler<MindwaveReadingEventArgs> CurrentValueChanged;

        /// <summary>
        /// Gets a value indicating whether the bluetooth socket is available and getting high quality data. 
        /// </summary>
        bool IsDataValid { get;  }

        /// <summary>
        /// Gets or sets the time between sensor updates. 
        /// </summary>
        TimeSpan TimeBetweenUpdates { get; set; }

        /// <summary>
        /// Gets the Bluetooth socket used for Mindwave. 
        /// </summary>
        /// <remarks>
        /// WARNING: Any change of state to the Socket might hurt the execution of this library.  
        /// </remarks>
        StreamSocket Socket { get; }

        /// <summary>
        /// Gets the PeerInformation used for Mindwave.
        /// </summary>
        /// <remarks>
        /// WARNING: any attempt to connect to this peer directly might hurt the exceution of this library.
        /// </remarks>
        PeerInformation PeerInformation { get; }

        /// <summary>
        /// Gets a value indicating whether the bluetooth socket is active.
        /// </summary>
        bool IsConnected { get; }
    }
}
